package cn.ibizlab.odoo.core.odoo_mrp.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Imrp_production;
import cn.ibizlab.odoo.core.odoo_mrp.domain.Mrp_production;
import cn.ibizlab.odoo.core.odoo_mrp.filter.Mrp_productionSearchContext;
import cn.ibizlab.odoo.core.odoo_mrp.service.IMrp_productionService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[Production Order] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Mrp_productionServiceImpl implements IMrp_productionService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Imrp_productionClientService mrp_productionClientService;

    @Override
    public boolean create(Mrp_production mrp_production) {
        boolean bOk = false ;
        Imrp_production clientModel = this.convert2Model(mrp_production,null);
        mrp_productionClientService.create(clientModel) ;
        this.convert2Domain(clientModel,mrp_production);
        bOk = true ;

        return bOk ;
    }

    @Override
    public boolean update(Mrp_production mrp_production) {
        boolean bOk = false ;
        Imrp_production clientModel = this.convert2Model(mrp_production,null);
        mrp_productionClientService.update(clientModel) ;
        this.convert2Domain(clientModel,mrp_production) ;
        bOk = true;
        return bOk ;
    }

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //mrp_productionClientService.removeBatch(mrp_productions) ;

    }

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Imrp_production clientModel = mrp_productionClientService.createModel();
        clientModel.setId(id);
        mrp_productionClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    @Override
    public void createBatch(List<Mrp_production> mrp_productions, int batchSize) {

                        //mrp_productionClientService.createBatch(mrp_productions,batchSize) ;

    }

    @Override
    public Mrp_production get(Integer id) {
        Imrp_production clientModel = mrp_productionClientService.createModel();
        clientModel.setId(id);
        mrp_productionClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Mrp_production get(Mrp_production mrp_production) {
        Mrp_production retmrp_production = this.get(mrp_production.getId()) ;
    	BeanCopier copier=BeanCopier.create(retmrp_production.getClass(), mrp_production.getClass(), false);
        copier.copy(retmrp_production, mrp_production, null);
        return mrp_production ;
    }

    @Override
    public void updateBatch(List<Mrp_production> mrp_productions, int batchSize) {

        //mrp_productionClientService.updateBatch(mrp_productions,batchSize) ;

    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Mrp_production> searchDefault(Mrp_productionSearchContext context) {
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据物料清单查询
     */
    @Override
    public Page<Mrp_production> selectByOdoo_bom(Integer id){
        Mrp_productionSearchContext context = new Mrp_productionSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据工艺查询
     */
    @Override
    public Page<Mrp_production> selectByOdoo_routing(Integer id){
        Mrp_productionSearchContext context = new Mrp_productionSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据产品查询
     */
    @Override
    public Page<Mrp_production> selectByOdoo_product(Integer id){
        Mrp_productionSearchContext context = new Mrp_productionSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据公司查询
     */
    @Override
    public Page<Mrp_production> selectByOdoo_company(Integer id){
        Mrp_productionSearchContext context = new Mrp_productionSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Mrp_production> selectByOdoo_create(Integer id){
        Mrp_productionSearchContext context = new Mrp_productionSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Mrp_production> selectByOdoo_user(Integer id){
        Mrp_productionSearchContext context = new Mrp_productionSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Mrp_production> selectByOdoo_write(Integer id){
        Mrp_productionSearchContext context = new Mrp_productionSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据库存位置查询
     */
    @Override
    public Page<Mrp_production> selectByOdoo_location_dest(Integer id){
        Mrp_productionSearchContext context = new Mrp_productionSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据库存位置查询
     */
    @Override
    public Page<Mrp_production> selectByOdoo_location_src(Integer id){
        Mrp_productionSearchContext context = new Mrp_productionSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据拣货类型查询
     */
    @Override
    public Page<Mrp_production> selectByOdoo_picking_type(Integer id){
        Mrp_productionSearchContext context = new Mrp_productionSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据产品计量单位查询
     */
    @Override
    public Page<Mrp_production> selectByOdoo_product_uom(Integer id){
        Mrp_productionSearchContext context = new Mrp_productionSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Mrp_production> list = new ArrayList<Mrp_production>();
        Page<cn.ibizlab.odoo.core.client.model.Imrp_production> clientModelList = mrp_productionClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Imrp_production clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Mrp_production>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Imrp_production convert2Model(Mrp_production domain , Imrp_production model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = mrp_productionClientService.createModel() ;
        }

         if(domain.getMessage_is_followerDirtyFlag())
            model.setMessage_is_follower(domain.getMessage_is_follower());
         if(domain.getActivity_summaryDirtyFlag())
            model.setActivity_summary(domain.getActivity_summary());
         if(domain.getWorkorder_done_countDirtyFlag())
            model.setWorkorder_done_count(domain.getWorkorder_done_count());
         if(domain.getFinished_move_line_idsDirtyFlag())
            model.setFinished_move_line_ids(domain.getFinished_move_line_ids());
         if(domain.getWebsite_message_idsDirtyFlag())
            model.setWebsite_message_ids(domain.getWebsite_message_ids());
         if(domain.getMessage_needaction_counterDirtyFlag())
            model.setMessage_needaction_counter(domain.getMessage_needaction_counter());
         if(domain.getMessage_main_attachment_idDirtyFlag())
            model.setMessage_main_attachment_id(domain.getMessage_main_attachment_id());
         if(domain.getMessage_attachment_countDirtyFlag())
            model.setMessage_attachment_count(domain.getMessage_attachment_count());
         if(domain.getQty_producedDirtyFlag())
            model.setQty_produced(domain.getQty_produced());
         if(domain.getPriorityDirtyFlag())
            model.setPriority(domain.getPriority());
         if(domain.getMessage_has_errorDirtyFlag())
            model.setMessage_has_error(domain.getMessage_has_error());
         if(domain.getUnreserve_visibleDirtyFlag())
            model.setUnreserve_visible(domain.getUnreserve_visible());
         if(domain.getHas_movesDirtyFlag())
            model.setHas_moves(domain.getHas_moves());
         if(domain.getIs_lockedDirtyFlag())
            model.setIs_locked(domain.getIs_locked());
         if(domain.getCreate_dateDirtyFlag())
            model.setCreate_date(domain.getCreate_date());
         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getActivity_type_idDirtyFlag())
            model.setActivity_type_id(domain.getActivity_type_id());
         if(domain.getDate_startDirtyFlag())
            model.setDate_start(domain.getDate_start());
         if(domain.getMove_finished_idsDirtyFlag())
            model.setMove_finished_ids(domain.getMove_finished_ids());
         if(domain.getScrap_countDirtyFlag())
            model.setScrap_count(domain.getScrap_count());
         if(domain.getScrap_idsDirtyFlag())
            model.setScrap_ids(domain.getScrap_ids());
         if(domain.getShow_final_lotsDirtyFlag())
            model.setShow_final_lots(domain.getShow_final_lots());
         if(domain.getNameDirtyFlag())
            model.setName(domain.getName());
         if(domain.getMove_dest_idsDirtyFlag())
            model.setMove_dest_ids(domain.getMove_dest_ids());
         if(domain.getProcurement_group_idDirtyFlag())
            model.setProcurement_group_id(domain.getProcurement_group_id());
         if(domain.getDelivery_countDirtyFlag())
            model.setDelivery_count(domain.getDelivery_count());
         if(domain.getProduct_qtyDirtyFlag())
            model.setProduct_qty(domain.getProduct_qty());
         if(domain.getActivity_idsDirtyFlag())
            model.setActivity_ids(domain.getActivity_ids());
         if(domain.getWorkorder_countDirtyFlag())
            model.setWorkorder_count(domain.getWorkorder_count());
         if(domain.getMessage_needactionDirtyFlag())
            model.setMessage_needaction(domain.getMessage_needaction());
         if(domain.getWrite_dateDirtyFlag())
            model.setWrite_date(domain.getWrite_date());
         if(domain.getMessage_channel_idsDirtyFlag())
            model.setMessage_channel_ids(domain.getMessage_channel_ids());
         if(domain.getDate_planned_finishedDirtyFlag())
            model.setDate_planned_finished(domain.getDate_planned_finished());
         if(domain.getActivity_date_deadlineDirtyFlag())
            model.setActivity_date_deadline(domain.getActivity_date_deadline());
         if(domain.getOriginDirtyFlag())
            model.setOrigin(domain.getOrigin());
         if(domain.getStateDirtyFlag())
            model.setState(domain.getState());
         if(domain.getDate_planned_startDirtyFlag())
            model.setDate_planned_start(domain.getDate_planned_start());
         if(domain.getMessage_follower_idsDirtyFlag())
            model.setMessage_follower_ids(domain.getMessage_follower_ids());
         if(domain.getMessage_idsDirtyFlag())
            model.setMessage_ids(domain.getMessage_ids());
         if(domain.getMessage_has_error_counterDirtyFlag())
            model.setMessage_has_error_counter(domain.getMessage_has_error_counter());
         if(domain.getCheck_to_doneDirtyFlag())
            model.setCheck_to_done(domain.getCheck_to_done());
         if(domain.getPost_visibleDirtyFlag())
            model.setPost_visible(domain.getPost_visible());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getPicking_idsDirtyFlag())
            model.setPicking_ids(domain.getPicking_ids());
         if(domain.getProduct_uom_qtyDirtyFlag())
            model.setProduct_uom_qty(domain.getProduct_uom_qty());
         if(domain.getMessage_unread_counterDirtyFlag())
            model.setMessage_unread_counter(domain.getMessage_unread_counter());
         if(domain.getConsumed_less_than_plannedDirtyFlag())
            model.setConsumed_less_than_planned(domain.getConsumed_less_than_planned());
         if(domain.getMove_raw_idsDirtyFlag())
            model.setMove_raw_ids(domain.getMove_raw_ids());
         if(domain.getAvailabilityDirtyFlag())
            model.setAvailability(domain.getAvailability());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getActivity_stateDirtyFlag())
            model.setActivity_state(domain.getActivity_state());
         if(domain.getWorkorder_idsDirtyFlag())
            model.setWorkorder_ids(domain.getWorkorder_ids());
         if(domain.getDate_finishedDirtyFlag())
            model.setDate_finished(domain.getDate_finished());
         if(domain.getMessage_partner_idsDirtyFlag())
            model.setMessage_partner_ids(domain.getMessage_partner_ids());
         if(domain.getPropagateDirtyFlag())
            model.setPropagate(domain.getPropagate());
         if(domain.getActivity_user_idDirtyFlag())
            model.setActivity_user_id(domain.getActivity_user_id());
         if(domain.getMessage_unreadDirtyFlag())
            model.setMessage_unread(domain.getMessage_unread());
         if(domain.getCompany_id_textDirtyFlag())
            model.setCompany_id_text(domain.getCompany_id_text());
         if(domain.getLocation_dest_id_textDirtyFlag())
            model.setLocation_dest_id_text(domain.getLocation_dest_id_text());
         if(domain.getLocation_src_id_textDirtyFlag())
            model.setLocation_src_id_text(domain.getLocation_src_id_text());
         if(domain.getProduction_location_idDirtyFlag())
            model.setProduction_location_id(domain.getProduction_location_id());
         if(domain.getProduct_id_textDirtyFlag())
            model.setProduct_id_text(domain.getProduct_id_text());
         if(domain.getWrite_uid_textDirtyFlag())
            model.setWrite_uid_text(domain.getWrite_uid_text());
         if(domain.getPicking_type_id_textDirtyFlag())
            model.setPicking_type_id_text(domain.getPicking_type_id_text());
         if(domain.getUser_id_textDirtyFlag())
            model.setUser_id_text(domain.getUser_id_text());
         if(domain.getProduct_tmpl_idDirtyFlag())
            model.setProduct_tmpl_id(domain.getProduct_tmpl_id());
         if(domain.getProduct_uom_id_textDirtyFlag())
            model.setProduct_uom_id_text(domain.getProduct_uom_id_text());
         if(domain.getCreate_uid_textDirtyFlag())
            model.setCreate_uid_text(domain.getCreate_uid_text());
         if(domain.getRouting_id_textDirtyFlag())
            model.setRouting_id_text(domain.getRouting_id_text());
         if(domain.getProduct_uom_idDirtyFlag())
            model.setProduct_uom_id(domain.getProduct_uom_id());
         if(domain.getProduct_idDirtyFlag())
            model.setProduct_id(domain.getProduct_id());
         if(domain.getRouting_idDirtyFlag())
            model.setRouting_id(domain.getRouting_id());
         if(domain.getWrite_uidDirtyFlag())
            model.setWrite_uid(domain.getWrite_uid());
         if(domain.getUser_idDirtyFlag())
            model.setUser_id(domain.getUser_id());
         if(domain.getCreate_uidDirtyFlag())
            model.setCreate_uid(domain.getCreate_uid());
         if(domain.getBom_idDirtyFlag())
            model.setBom_id(domain.getBom_id());
         if(domain.getLocation_src_idDirtyFlag())
            model.setLocation_src_id(domain.getLocation_src_id());
         if(domain.getPicking_type_idDirtyFlag())
            model.setPicking_type_id(domain.getPicking_type_id());
         if(domain.getCompany_idDirtyFlag())
            model.setCompany_id(domain.getCompany_id());
         if(domain.getLocation_dest_idDirtyFlag())
            model.setLocation_dest_id(domain.getLocation_dest_id());
        return model ;
    }

    public Mrp_production convert2Domain( Imrp_production model ,Mrp_production domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Mrp_production();
        }

        if(model.getMessage_is_followerDirtyFlag())
            domain.setMessage_is_follower(model.getMessage_is_follower());
        if(model.getActivity_summaryDirtyFlag())
            domain.setActivity_summary(model.getActivity_summary());
        if(model.getWorkorder_done_countDirtyFlag())
            domain.setWorkorder_done_count(model.getWorkorder_done_count());
        if(model.getFinished_move_line_idsDirtyFlag())
            domain.setFinished_move_line_ids(model.getFinished_move_line_ids());
        if(model.getWebsite_message_idsDirtyFlag())
            domain.setWebsite_message_ids(model.getWebsite_message_ids());
        if(model.getMessage_needaction_counterDirtyFlag())
            domain.setMessage_needaction_counter(model.getMessage_needaction_counter());
        if(model.getMessage_main_attachment_idDirtyFlag())
            domain.setMessage_main_attachment_id(model.getMessage_main_attachment_id());
        if(model.getMessage_attachment_countDirtyFlag())
            domain.setMessage_attachment_count(model.getMessage_attachment_count());
        if(model.getQty_producedDirtyFlag())
            domain.setQty_produced(model.getQty_produced());
        if(model.getPriorityDirtyFlag())
            domain.setPriority(model.getPriority());
        if(model.getMessage_has_errorDirtyFlag())
            domain.setMessage_has_error(model.getMessage_has_error());
        if(model.getUnreserve_visibleDirtyFlag())
            domain.setUnreserve_visible(model.getUnreserve_visible());
        if(model.getHas_movesDirtyFlag())
            domain.setHas_moves(model.getHas_moves());
        if(model.getIs_lockedDirtyFlag())
            domain.setIs_locked(model.getIs_locked());
        if(model.getCreate_dateDirtyFlag())
            domain.setCreate_date(model.getCreate_date());
        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getActivity_type_idDirtyFlag())
            domain.setActivity_type_id(model.getActivity_type_id());
        if(model.getDate_startDirtyFlag())
            domain.setDate_start(model.getDate_start());
        if(model.getMove_finished_idsDirtyFlag())
            domain.setMove_finished_ids(model.getMove_finished_ids());
        if(model.getScrap_countDirtyFlag())
            domain.setScrap_count(model.getScrap_count());
        if(model.getScrap_idsDirtyFlag())
            domain.setScrap_ids(model.getScrap_ids());
        if(model.getShow_final_lotsDirtyFlag())
            domain.setShow_final_lots(model.getShow_final_lots());
        if(model.getNameDirtyFlag())
            domain.setName(model.getName());
        if(model.getMove_dest_idsDirtyFlag())
            domain.setMove_dest_ids(model.getMove_dest_ids());
        if(model.getProcurement_group_idDirtyFlag())
            domain.setProcurement_group_id(model.getProcurement_group_id());
        if(model.getDelivery_countDirtyFlag())
            domain.setDelivery_count(model.getDelivery_count());
        if(model.getProduct_qtyDirtyFlag())
            domain.setProduct_qty(model.getProduct_qty());
        if(model.getActivity_idsDirtyFlag())
            domain.setActivity_ids(model.getActivity_ids());
        if(model.getWorkorder_countDirtyFlag())
            domain.setWorkorder_count(model.getWorkorder_count());
        if(model.getMessage_needactionDirtyFlag())
            domain.setMessage_needaction(model.getMessage_needaction());
        if(model.getWrite_dateDirtyFlag())
            domain.setWrite_date(model.getWrite_date());
        if(model.getMessage_channel_idsDirtyFlag())
            domain.setMessage_channel_ids(model.getMessage_channel_ids());
        if(model.getDate_planned_finishedDirtyFlag())
            domain.setDate_planned_finished(model.getDate_planned_finished());
        if(model.getActivity_date_deadlineDirtyFlag())
            domain.setActivity_date_deadline(model.getActivity_date_deadline());
        if(model.getOriginDirtyFlag())
            domain.setOrigin(model.getOrigin());
        if(model.getStateDirtyFlag())
            domain.setState(model.getState());
        if(model.getDate_planned_startDirtyFlag())
            domain.setDate_planned_start(model.getDate_planned_start());
        if(model.getMessage_follower_idsDirtyFlag())
            domain.setMessage_follower_ids(model.getMessage_follower_ids());
        if(model.getMessage_idsDirtyFlag())
            domain.setMessage_ids(model.getMessage_ids());
        if(model.getMessage_has_error_counterDirtyFlag())
            domain.setMessage_has_error_counter(model.getMessage_has_error_counter());
        if(model.getCheck_to_doneDirtyFlag())
            domain.setCheck_to_done(model.getCheck_to_done());
        if(model.getPost_visibleDirtyFlag())
            domain.setPost_visible(model.getPost_visible());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getPicking_idsDirtyFlag())
            domain.setPicking_ids(model.getPicking_ids());
        if(model.getProduct_uom_qtyDirtyFlag())
            domain.setProduct_uom_qty(model.getProduct_uom_qty());
        if(model.getMessage_unread_counterDirtyFlag())
            domain.setMessage_unread_counter(model.getMessage_unread_counter());
        if(model.getConsumed_less_than_plannedDirtyFlag())
            domain.setConsumed_less_than_planned(model.getConsumed_less_than_planned());
        if(model.getMove_raw_idsDirtyFlag())
            domain.setMove_raw_ids(model.getMove_raw_ids());
        if(model.getAvailabilityDirtyFlag())
            domain.setAvailability(model.getAvailability());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getActivity_stateDirtyFlag())
            domain.setActivity_state(model.getActivity_state());
        if(model.getWorkorder_idsDirtyFlag())
            domain.setWorkorder_ids(model.getWorkorder_ids());
        if(model.getDate_finishedDirtyFlag())
            domain.setDate_finished(model.getDate_finished());
        if(model.getMessage_partner_idsDirtyFlag())
            domain.setMessage_partner_ids(model.getMessage_partner_ids());
        if(model.getPropagateDirtyFlag())
            domain.setPropagate(model.getPropagate());
        if(model.getActivity_user_idDirtyFlag())
            domain.setActivity_user_id(model.getActivity_user_id());
        if(model.getMessage_unreadDirtyFlag())
            domain.setMessage_unread(model.getMessage_unread());
        if(model.getCompany_id_textDirtyFlag())
            domain.setCompany_id_text(model.getCompany_id_text());
        if(model.getLocation_dest_id_textDirtyFlag())
            domain.setLocation_dest_id_text(model.getLocation_dest_id_text());
        if(model.getLocation_src_id_textDirtyFlag())
            domain.setLocation_src_id_text(model.getLocation_src_id_text());
        if(model.getProduction_location_idDirtyFlag())
            domain.setProduction_location_id(model.getProduction_location_id());
        if(model.getProduct_id_textDirtyFlag())
            domain.setProduct_id_text(model.getProduct_id_text());
        if(model.getWrite_uid_textDirtyFlag())
            domain.setWrite_uid_text(model.getWrite_uid_text());
        if(model.getPicking_type_id_textDirtyFlag())
            domain.setPicking_type_id_text(model.getPicking_type_id_text());
        if(model.getUser_id_textDirtyFlag())
            domain.setUser_id_text(model.getUser_id_text());
        if(model.getProduct_tmpl_idDirtyFlag())
            domain.setProduct_tmpl_id(model.getProduct_tmpl_id());
        if(model.getProduct_uom_id_textDirtyFlag())
            domain.setProduct_uom_id_text(model.getProduct_uom_id_text());
        if(model.getCreate_uid_textDirtyFlag())
            domain.setCreate_uid_text(model.getCreate_uid_text());
        if(model.getRouting_id_textDirtyFlag())
            domain.setRouting_id_text(model.getRouting_id_text());
        if(model.getProduct_uom_idDirtyFlag())
            domain.setProduct_uom_id(model.getProduct_uom_id());
        if(model.getProduct_idDirtyFlag())
            domain.setProduct_id(model.getProduct_id());
        if(model.getRouting_idDirtyFlag())
            domain.setRouting_id(model.getRouting_id());
        if(model.getWrite_uidDirtyFlag())
            domain.setWrite_uid(model.getWrite_uid());
        if(model.getUser_idDirtyFlag())
            domain.setUser_id(model.getUser_id());
        if(model.getCreate_uidDirtyFlag())
            domain.setCreate_uid(model.getCreate_uid());
        if(model.getBom_idDirtyFlag())
            domain.setBom_id(model.getBom_id());
        if(model.getLocation_src_idDirtyFlag())
            domain.setLocation_src_id(model.getLocation_src_id());
        if(model.getPicking_type_idDirtyFlag())
            domain.setPicking_type_id(model.getPicking_type_id());
        if(model.getCompany_idDirtyFlag())
            domain.setCompany_id(model.getCompany_id());
        if(model.getLocation_dest_idDirtyFlag())
            domain.setLocation_dest_id(model.getLocation_dest_id());
        return domain ;
    }


}
